import { ElMessage } from 'element-plus';
import router from '@/router/index.js';
const switchPage = (biz) => {
  const {
    recordType,

    recordId,
    module, // 上报使用

    id,
    planYear,
    planType,
    plannedMonth,
    plannedQuarter, // 计划消息使用
  } = biz;
  // 1,2,3-质控，4-夜查房
  if ([1, 2, 3, 4].includes(recordType)) {
    goRecord(module, recordId);
    return;
  }

  if ([5].includes(recordType)) {
    goPlan(id, planYear, planType, plannedMonth, plannedQuarter);
  }
};

function goPlan(id, planYear, planType, plannedMonth, plannedQuarter) {
  router.push({
    path: '/QCReportRecord/QCPlan',
    query: { id, planYear, planType, plannedMonth, plannedQuarter },
  });
}
function goRecord(module, id) {
  const errMsg = [];
  if (!module) errMsg.push('module');
  if (!id) errMsg.push('recordId');
  if (errMsg.length)
    return ElMessage({
      message: `数据异常${errMsg.join(',')}为空:`,
      type: 'error',
    });
  router.push({
    path: '/QCReportRecord/QCFormDetail',
    query: { formType: module, id },
  });
}

export default switchPage;
